package com.boarsoft.flow.demo.login;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.boarsoft.flow.core.bean.ProcessHandler;
import com.boarsoft.flow.demo.bean.User;

public class LoginHandlerImpl implements ProcessHandler {
	private static final Logger log = LoggerFactory.getLogger(LoginHandlerImpl.class);
	
	protected String encode;

	@Override
	public Object process(String entry, Object data, Throwable e) throws InterruptedException {
		Thread.sleep(10L);
		User u = (User) data;
		log.info("User {} login with encode {}", u.getName(), encode);
		if ("Mac_J".equals(u.getName()) && "123".equals(u.getPassword())) {
			u.setId("00000000000000000000000000000000");
		}
		return u;
	}

	public String getEncode() {
		return encode;
	}

	public void setEncode(String encode) {
		this.encode = encode;
	}
}
